<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        //类内部如何为『实例对象』添加『属性』
        class Person{
            // 属性
            name = '人类';
            age = 20;
            run = () => {
                console.log('我可以跑');
            }

            // 方法
            constructor(){
                this.name = '人儿';
            }

            run(){
                console.log('跑步');
            }
        }


        class Student extends Person{

            constructor(){
                super();// 语法限制  必须要写   super 调用的父类的构造方法
            }

            run(){
                console.log('123');
            }

        }

        let me = new Student();
        // console.log(me);
        console.log(me);


        //实例化
        // let renziwei = new Person();

        // console.log(renziwei);
        // renziwei.run();

        function A(name, age, height, weight){
            this.name = name;
            this.age = age;
            this.height = height;
            this.weight = weight;
        }

        function B(name, age, height, weight){
            //关键代码
            A.call(this, name); // 简化代码
        }

    </script>
</body>
</html>